﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DAL;

namespace PeisongWeb.admin
{
    public partial class deductPercentageList :adminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (hasPermission("GD", 1))
                {
                    rpt_Bind();
                }
                else
                {
                    Library.Script.ClientMsgUrl("没有权限！", "index.aspx");
                    return;
                }
            }
        }

        void rpt_Bind()
        {
            DataTable dt = new DataTable();
            dt = logic.deductPercentage.list();
            rpt_list.DataSource = dt;
            rpt_list.DataBind();
        }
        protected void btn_save_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < rpt_list.Items.Count; i++)    //修改提成比例
            {
                RepeaterItem row = rpt_list.Items[i];
                HiddenField hid = row.FindControl("hid_dpid") as HiddenField;
                TextBox txtseasonRate = row.FindControl("txt_seasonRate") as TextBox;
                TextBox txtyearendRate = row.FindControl("txt_yearendRate") as TextBox;
                DeductPercentageEntity dpEnt = new DeductPercentageEntity();
                if (txtseasonRate.Text.Trim() != "" && txtyearendRate.Text.Trim()!="")
                {
                    dpEnt.dpid =  Convert.ToInt32(hid.Value);
                    dpEnt.seasonRate = Convert.ToDecimal(txtseasonRate.Text);
                    dpEnt.yearendRate = Convert.ToDecimal(txtyearendRate.Text);
                    logic.deductPercentage.update(dpEnt);
                }
            }
            Library.Script.ClientMsg("修改提成比例成功！");
            rpt_Bind();
        }
    }
}
